<?php
defined('SYSPATH') OR die('No direct access allowed.');
/**
 * customer.php
 * @author ranuandra
 *
 * 15 Agu 2011 09:57:06
 *
 * 
 */
$jumlah = 0;
$persen = 0;
if(isset($datas))
{
	foreach($datas as $data)
	{
		$jumlah += $data['jumlah'];
	}
}

if($jumlah > 0)
{
	$persen = $jumlah * (30/100);
}
if(isset($header))
{

		echo $header;
}
?>

<div class="tbldata">
<!--  <table class="data tablesorter" class="center"> -->
<table class="data" class="center">
	<thead>
		<tr>
			<th>No</th>
			<th>Nama</th>
			<th>Alamat</th>
			<th>Area</th>
			<th>Jumlah Kendaraan</th>
			<th>Detail</th>
		</tr>
	</thead>
	<tbody>
<?php 
if(isset($datas))
{
	$i = 0;
	$pareto = 0;
	foreach($datas as $data)
	{
		$i++;
		
		$post = $_POST;
		$post['customer'] = $data['id'];
		$polreg = new Model_Report();
			//$datas = $polreg->data_by_type();
		$details = $polreg->detail_customer($post, 0);
		//print_r($details);
		//$jumlah += $data['jumlah'];
		//$pareto += $data['jumlah'];
		$txtdetail = "";
		foreach($details as $detail)
		{
			$txtdetail .= $detail['type'].' '.$detail['merk'].'='.$detail['jumlah'].', ';
		}
		if($data['jumlah'] <= $pareto)
		{
?>
		<tr class="pareto">
<?php 
		} else {
				
?>
		<tr>
<?php 
		}
?>

			<td><?php //echo $data['id'] 
						echo $i ?></td>
			<td><a href="<?php echo URL::base() ?>report/detail" class="linkajax" targetdata=".contain" refid="<?php echo $data['id']?>"><?php echo $data['nama']?></a></td>
			<td><?php echo $data['alamat']?></td>	
			<td><?php echo $data['area']?></td>	
			<td class="tip" title="<?php //echo $txtdetail ?>"><span><?php echo $data['jumlah']?></span></td>	
			<td><?php echo $txtdetail ?></td>	
		</tr>
	
<?php 	
		 
			
	}
}
?>	
	</tbody>
	<tfoot>
		<tr>
			<td><?php echo $i ?></td>
			<td></td>
			<td></td>
			<td></td>		
			<td><?php echo $jumlah?></td>
			<td></td>
		</tr>
	</tfoot>
	</table>
</div>